﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

public partial class UserControl_SearchProduct : System.Web.UI.UserControl
{
    ShopLaptopConnection conn;
    protected void Page_Load(object sender, EventArgs e)
    {
        conn = new ShopLaptopConnection();
        if (!IsPostBack)
        {
            DisplayDrdlProductSearch();
        }
    }
    protected void imgSearch_Click(object sender, ImageClickEventArgs e)
    {
        if (drdlProductCate.SelectedIndex == 0)
        {
            Response.Redirect("Default.aspx?proName=" + txtProductSearch.Text);
        }
        else
        {
            Response.Redirect("Default.aspx?cateID="+drdlProductCate.SelectedValue+"&proName=" + txtProductSearch.Text);
        }
    }

    protected void DisplayDrdlProductSearch()
    {
        List<Category> list = conn.GetAllCategoryByStatus1();
        foreach (Category cate in list)
        {
            ListItem item = new ListItem(cate.CateName,cate.CateID.ToString());
            drdlProductCate.Items.Add(item);
        }
    }
}
